Browse Source

web member add

shjung 3 years ago
parent
commit
abc5d7501c

+ 6 - 0
pom.xml

@@ -56,6 +56,12 @@
             <artifactId>jansi</artifactId>
             <version>1.8</version>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec 비번, base64 -->
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.15</version>
+        </dependency>
 
         <dependency>
             <groupId>com.oracle</groupId>

+ 72 - 0
src/main/java/com/its/op/controller/its/database/TbMsWebMemberController.java

@@ -0,0 +1,72 @@
+package com.its.op.controller.its.database;
+
+import com.its.op.dto.its.oper.TbMsWebMemberDto;
+import com.its.op.service.its.oper.TbMsWebMemberService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+@Api(tags = "09.기초데이터관리-14.홈페이지관리자관리")
+@Validated
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/api/database/web-member")
+public class TbMsWebMemberController {
+
+    private final TbMsWebMemberService service;
+
+    @ApiOperation(value = "홈페이지관리자 전체조회(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class, responseContainer = "ArrayList")
+    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
+    public List<TbMsWebMemberDto> findAll() {
+        return this.service.findAll();
+    }
+
+    @ApiOperation(value = "홈페이지관리자 개별조회(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class)
+    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
+    public TbMsWebMemberDto findById(@PathVariable final String id) {
+        return this.service.findById(id);
+    }
+
+    @ApiOperation(value = "홈페이지관리자 계정잠금 해제", response = TbMsWebMemberDto.class)
+    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
+    public TbMsWebMemberDto accountLockFree(@PathVariable final String id) {
+        return this.service.accountLockFree(id);
+    }
+
+
+//    @ApiOperation(value = " 정보변경(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class)
+//    @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
+//    public TbMsWebMemberDto updateById(@PathVariable final String id, @RequestBody @Valid final TbMsWebMemberDto.TbMsWebMemberUpdReq req) {
+//        return this.service.updateById(id, req);
+//    }
+//
+//    @ApiOperation(value = " 정보변경/생성-목록(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class, responseContainer = "ArrayList")
+//    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
+//    public List<TbMsWebMemberDto> mergeInfoList(@RequestBody @Valid final List<TbMsWebMemberDto.TbMsWebMemberUpdReq> listReq) {
+//        return this.service.mergeInfoList(listReq);
+//    }
+
+    @ApiOperation(value = "홈페이지관리자 정보변경/생성-개별(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class)
+    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
+    public TbMsWebMemberDto mergeInfo(@PathVariable("id") String id, @RequestBody @Valid final TbMsWebMemberDto.TbMsWebMemberUpdReq req) {
+        return this.service.mergeInfo(req);
+    }
+
+    @ApiOperation(value = "홈페이지관리자 정보삭제-개별(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class)
+    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
+    public TbMsWebMemberDto deleteDataById(@PathVariable("id") String id) {
+        return this.service.deleteById(id);
+    }
+
+//    @ApiOperation(value = " 정보삭제-목록(TB_MS_WEB_MEMBER)", response = TbMsWebMemberDto.class, responseContainer = "ArrayList")
+//    @DeleteMapping(value = "", produces = {"application/json; charset=utf8"})
+//    public List<TbMsWebMemberDto> deleteDataByIds(@RequestBody @Valid final List<String> ids) {
+//        return this.service.deleteByIds(ids);
+//    }
+
+}

+ 11 - 0
src/main/java/com/its/op/dao/repository/its/oper/TbMsWebMemberRepository.java

@@ -0,0 +1,11 @@
+package com.its.op.dao.repository.its.oper;
+
+import com.its.op.entity.its.oper.TbMsWebMember;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface TbMsWebMemberRepository extends JpaRepository<TbMsWebMember, String>, JpaSpecificationExecutor<TbMsWebMember> {
+
+}

+ 209 - 0
src/main/java/com/its/op/dto/its/oper/TbMsWebMemberDto.java

@@ -0,0 +1,209 @@
+package com.its.op.dto.its.oper;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.its.op.entity.its.oper.TbMsWebMember;
+import com.its.utils.AES256Util;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Positive;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+/**
+ *  DTO Class
+ */
+@Data
+@Builder
+@ApiModel("TbMsWebMemberDto(홈페이지관리자정보)")
+public class TbMsWebMemberDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("아이디")  // N VARCHAR(50)
+    @JsonProperty("email")
+    private String email;
+
+    @ApiModelProperty("관리자명")  // Y VARCHAR(15)
+    @JsonProperty("username")
+    private String username;
+
+    @ApiModelProperty("비번")  // Y VARCHAR(100)
+    @JsonProperty("password")
+    private String password;
+
+    @ApiModelProperty("연락처")  // Y VARCHAR(20)
+    @JsonProperty("contactnum")
+    private String contactnum;
+
+    @ApiModelProperty("권한명")  // Y VARCHAR(3)
+    @JsonProperty("userauth")
+    private String userauth;
+
+    @ApiModelProperty("비밀번호질문")  // Y VARCHAR(200)
+    @JsonProperty("question")
+    private String question;
+
+    @ApiModelProperty("비밀번호응답")  // Y VARCHAR(100)
+    @JsonProperty("answer")
+    private String answer;
+
+    @ApiModelProperty("등록시각")  // Y DATE(0)
+    @JsonProperty("regdate")
+    private String regdate;
+
+    @ApiModelProperty("로그인 실패 횟수")  // Y NUMBER(3)
+    @JsonProperty("login_fail_count")
+    private Integer loginFailCount;
+
+    @ApiModelProperty("계정잠금여부(Y:계정잠김)")  // Y CHAR(1)
+    @JsonProperty("is_account_lock")
+    private String isAccountLock;
+
+    @ApiModelProperty("관리자계정접속가능아이피")  // Y VARCHAR(200)
+    @JsonProperty("ip_address")
+    private String ipAddress;
+
+    @ApiModelProperty("삭제여부(Y:삭제됨)")  // Y CHAR(1)
+    @JsonProperty("del_yn")
+    private String delYn;
+
+    // Code Description Field
+    @ApiModelProperty("삭제여부(Y:삭제됨) 설명")
+    @JsonProperty("del_desc")    // DEL_YN
+    private String delDesc;
+
+    @ApiModel("TbMsWebMemberUpdReq(홈페이지관리자정보 정보변경)")
+    @Getter
+    @Setter
+    @ToString
+    @NoArgsConstructor(access = AccessLevel.PROTECTED)
+    public static class TbMsWebMemberUpdReq {
+
+        @ApiModelProperty("메일주소, Nullable = N, VARCHAR(50)")  // N VARCHAR(50)
+        @JsonProperty("아이디")
+        @Size(min=1, max=50)
+        private String email;
+
+        @ApiModelProperty("관리자명, Nullable = Y, VARCHAR(15)")  // Y VARCHAR(15)
+        @JsonProperty("username")
+        @Size(min=1, max=15)
+        private String username;
+
+        @ApiModelProperty("비번, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
+        @JsonProperty("password")
+        @Size(min=1, max=100)
+        private String password;
+
+        @ApiModelProperty("연락처, Nullable = Y, VARCHAR(20)")  // Y VARCHAR(20)
+        @JsonProperty("contactnum")
+        @Size(min=1, max=20)
+        private String contactnum;
+
+        @ApiModelProperty("권한명, Nullable = Y, VARCHAR(3)")  // Y VARCHAR(3)
+        @JsonProperty("userauth")
+        @Size(min=1, max=3)
+        private String userauth;
+
+        @ApiModelProperty("비밀번호질문, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
+        @JsonProperty("question")
+        @Size(max=200)
+        private String question;
+
+        @ApiModelProperty("비밀번호응답, Nullable = Y, VARCHAR(100)")  // Y VARCHAR(100)
+        @JsonProperty("answer")
+        @Size(max=100)
+        private String answer;
+
+        @ApiModelProperty("등록시각, Nullable = Y, DATE(0)")  // Y DATE(0)
+        @JsonProperty("regdate")
+        private String regdate;
+
+        @ApiModelProperty("로그인 실패 횟수, Nullable = Y, NUMBER(3)")  // Y NUMBER(3)
+        @JsonProperty("login_fail_count")
+        @Positive
+        private Integer loginFailCount;
+
+        @ApiModelProperty("계정잠금여부(Y:계정잠김), Nullable = Y, CHAR(1)")  // Y CHAR(1)
+        @JsonProperty("is_account_lock")
+        @Size(min=1, max=1)
+        @Pattern(regexp = "[YN]")
+        private String isAccountLock;
+
+        @ApiModelProperty("관리자계정접속가능아이피, Nullable = Y, VARCHAR(200)")  // Y VARCHAR(200)
+        @JsonProperty("ip_address")
+        @Size(min=1, max=200)
+        private String ipAddress;
+
+        @ApiModelProperty("삭제여부(Y:삭제됨), Nullable = Y, CHAR(1)")  // Y CHAR(1)
+        @JsonProperty("del_yn")
+        @Size(min=1, max=1)
+        @Pattern(regexp = "[YN]")
+        private String delYn;
+
+        @Builder
+        public TbMsWebMemberUpdReq(String email, String username, String password, String contactnum, String userauth, String question, String answer, String regdate, Integer login_fail_count, String is_account_lock, String ip_address, String del_yn) {
+            this.email = email;
+            this.username = username;
+            this.password = password;
+            this.contactnum = contactnum;
+            this.userauth = userauth;
+            this.question = question;
+            this.answer = answer;
+            this.regdate = regdate;
+            this.loginFailCount = login_fail_count;
+            this.isAccountLock = is_account_lock;
+            this.ipAddress = ip_address;
+            this.delYn = del_yn;
+        }
+        @ApiModel("TbMsWebMemberUpdReq(홈페이지관리자정보 락 해제)")
+        @Getter
+        @Setter
+        @ToString
+        @NoArgsConstructor(access = AccessLevel.PROTECTED)
+        public static class TbMsWebMemberLockFreeReq {
+
+            @ApiModelProperty("아이디, Nullable = N, VARCHAR(50)")  // N VARCHAR(50)
+            @JsonProperty("email")
+            @Size(min = 1, max = 50)
+            private String email;
+
+            @Builder
+            public TbMsWebMemberLockFreeReq(String email) {
+                this.email = email;
+            }
+        }
+
+        public TbMsWebMember toEntity() {
+            AES256Util aes = null;
+            String encodePassword = "";
+            try {
+                aes = new AES256Util(AES256Util.DEFAULT_KEY);
+                encodePassword = aes.aesEncode(this.password); // 암호화
+                //decodePassword = aes.aesDecode(password); // 복호화
+            } catch (UnsupportedEncodingException e) {
+                encodePassword = this.password;
+            } catch (Exception e) {
+                encodePassword = this.password;
+            }
+            return TbMsWebMember.builder()
+                    .email(this.email)
+                    .username(this.username)
+                    .password(encodePassword)
+                    .contactnum(this.contactnum)
+                    .userauth(this.userauth)
+                    .question(this.question)
+                    .answer(this.answer)
+                    .regdate(this.regdate)
+                    .loginFailCount(this.loginFailCount)
+                    .isAccountLock(this.isAccountLock)
+                    .ipAddress(this.ipAddress)
+                    .delYn(this.delYn)
+                    .build();
+        }
+
+    }
+
+}

+ 126 - 0
src/main/java/com/its/op/entity/its/oper/TbMsWebMember.java

@@ -0,0 +1,126 @@
+package com.its.op.entity.its.oper;
+
+import com.its.op.dto.its.oper.TbMsWebMemberDto;
+import com.its.utils.AES256Util;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+/**
+ *  Entity Class
+ */
+@Getter
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
+@Builder
+@AllArgsConstructor
+@ApiModel("")
+@Entity
+@Table(name = "TB_MS_WEB_MEMBER")
+public class TbMsWebMember implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("아이디")  // N VARCHAR(50)
+    @Id
+    @Column(name = "EMAIL", nullable = false, length = 50)
+    private String email;
+
+    @ApiModelProperty("관리자명")  // Y VARCHAR(15)
+    @Column(name = "USERNAME", length = 15)
+    private String username;
+
+    @ApiModelProperty("비번")  // Y VARCHAR(100)
+    @Column(name = "PASSWORD", length = 100)
+    private String password;
+
+    @ApiModelProperty("연락처")  // Y VARCHAR(20)
+    @Column(name = "CONTACTNUM", length = 20)
+    private String contactnum;
+
+    @ApiModelProperty("권한명")  // Y VARCHAR(3)
+    @Column(name = "USERAUTH", length = 3)
+    private String userauth;
+
+    @ApiModelProperty("비밀번호질문")  // Y VARCHAR(200)
+    @Column(name = "QUESTION", length = 200)
+    private String question;
+
+    @ApiModelProperty("비밀번호응답")  // Y VARCHAR(100)
+    @Column(name = "ANSWER", length = 100)
+    private String answer;
+
+    @ApiModelProperty("등록시각")  // Y DATE(0)
+    @Column(name = "REGDATE", length = 0)
+    private String regdate;
+
+    @ApiModelProperty("로그인 실패 횟수")  // Y NUMBER(3)
+    @Column(name = "LOGIN_FAIL_COUNT", columnDefinition = "NUMBER", length = 3)
+    private Integer loginFailCount;
+
+    @ApiModelProperty("계정잠금여부(Y:계정잠김)")  // Y CHAR(1)
+    @Column(name = "IS_ACCOUNT_LOCK", columnDefinition = "CHAR", length = 1)
+    private String isAccountLock;
+
+    @ApiModelProperty("관리자계정접속가능아이피")  // Y VARCHAR(200)
+    @Column(name = "IP_ADDRESS", length = 200)
+    private String ipAddress;
+
+    @ApiModelProperty("삭제여부(Y:삭제됨)")  // Y CHAR(1)
+    @Column(name = "DEL_YN", columnDefinition = "CHAR", length = 1)
+    private String delYn;
+
+    public void setAccountLockFree() {
+        this.loginFailCount = 0;
+        this.isAccountLock = "N";
+    }
+    public TbMsWebMemberDto toDto() {
+        return TbMsWebMemberDto.builder()
+                .email(this.email)
+                .username(this.username)
+                .password(this.password)
+                .contactnum(this.contactnum)
+                .userauth(this.userauth)
+                .question(this.question)
+                .answer(this.answer)
+                .regdate(this.regdate)
+                .loginFailCount(this.loginFailCount)
+                .isAccountLock(this.isAccountLock)
+                .ipAddress(this.ipAddress)
+                .delYn(this.delYn)
+                .build();
+    }
+
+    public void updateInfo(TbMsWebMemberDto.TbMsWebMemberUpdReq req) {
+        AES256Util aes = null;
+        String encodePassword = "";
+        try {
+            aes = new AES256Util(AES256Util.DEFAULT_KEY);
+            encodePassword = aes.aesEncode(req.getPassword()); // 암호화
+            //decodePassword = aes.aesDecode(password); // 복호화
+        } catch (UnsupportedEncodingException e) {
+            encodePassword = req.getPassword();
+        } catch (Exception e) {
+            encodePassword = req.getPassword();
+        }
+
+        this.email = req.getEmail();
+        this.username = req.getUsername();
+        this.password = encodePassword;
+        this.contactnum = req.getContactnum();
+        this.userauth = req.getUserauth();
+        this.question = req.getQuestion();
+        this.answer = req.getAnswer();
+        this.regdate = req.getRegdate();
+        this.loginFailCount = req.getLoginFailCount();
+        this.isAccountLock = req.getIsAccountLock();
+        this.ipAddress = req.getIpAddress();
+        this.delYn = req.getDelYn();
+    }
+
+}

+ 112 - 0
src/main/java/com/its/op/service/its/oper/TbMsWebMemberService.java

@@ -0,0 +1,112 @@
+package com.its.op.service.its.oper;
+
+import com.its.op.dao.repository.its.oper.TbMsWebMemberRepository;
+import com.its.op.dto.its.oper.TbMsWebMemberDto;
+import com.its.op.entity.its.oper.TbMsWebMember;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class TbMsWebMemberService {
+
+    private final TbMsWebMemberRepository repo;
+
+    // 데이터 1건 조회, 없으면 exception
+    private TbMsWebMember requireOne(String id) throws NoSuchElementException {
+        Optional<TbMsWebMember> info = this.repo.findById(id);
+        if (info.isPresent()) {
+            return info.get();
+        }
+        else {
+            throw new NoSuchElementException("데이터가 존재하지 않습니다: " + id);
+        }
+//        return this.repo.findById(id)
+//                .orElseThrow(() -> new NoSuchElementException("데이터가 존재하지 않습니다: " + id));
+    }
+
+    // 전체 데이터 조회
+    @Transactional(readOnly = true)
+    public List<TbMsWebMemberDto> findAll() {
+        List<TbMsWebMemberDto> result = new ArrayList<>();
+        List<TbMsWebMember> data = this.repo.findAll();
+        for (TbMsWebMember entity : data) {
+            result.add(entity.toDto());
+        }
+        return result;
+    }
+
+    // 데이터 1건 조회(기존 데이터가 반드시 존재해야 함)
+    @Transactional(readOnly = true)
+    public TbMsWebMemberDto findById(String id) {
+        TbMsWebMember entity = requireOne(id);
+        return entity.toDto();
+    }
+
+    // 데이터 변경
+    @Transactional
+    public TbMsWebMemberDto updateById(String id, TbMsWebMemberDto.TbMsWebMemberUpdReq req) {
+        TbMsWebMember entity = requireOne(id);
+        entity.updateInfo(req);
+        this.repo.save(entity);
+        return entity.toDto();
+    }
+
+    // 데이터 변경 또는 생성-목록(데이터가 존재하면 업데이트 없으면 신규로 생성)
+    @Transactional
+    public List<TbMsWebMemberDto> mergeInfoList(List<TbMsWebMemberDto.TbMsWebMemberUpdReq> reqList) {
+        List<TbMsWebMemberDto> result = new ArrayList<>();
+        for (TbMsWebMemberDto.TbMsWebMemberUpdReq req : reqList) {
+            TbMsWebMember obj = req.toEntity();
+            this.repo.save(obj);
+            result.add(obj.toDto());
+        }
+        return result;
+    }
+
+    // 데이터 변경 또는 생성-개별(데이터가 존재하면 업데이트 없으면 신규로 생성)
+    @Transactional
+    public TbMsWebMemberDto mergeInfo(TbMsWebMemberDto.TbMsWebMemberUpdReq req) {
+        TbMsWebMember obj = req.toEntity();
+        this.repo.save(obj);
+        return obj.toDto();
+    }
+
+    // 정보 삭제-개별, 데이터 존재하지 않으면 Exception
+    @Transactional
+    public TbMsWebMemberDto deleteById(String id) {
+        TbMsWebMember entity = requireOne(id);
+        this.repo.deleteById(id);
+        return entity.toDto();
+    }
+
+    // 정보 삭제-목록, 존재하는 데이터 만 삭제
+    @Transactional
+    public List<TbMsWebMemberDto> deleteByIds(List<String> ids) {
+        List<TbMsWebMemberDto> result = new ArrayList<>();
+        for (String id : ids) {
+            Optional<TbMsWebMember> obj = this.repo.findById(id);
+            if (obj.isPresent()) {
+                this.repo.deleteById(id);
+                result.add(obj.get().toDto());
+            }
+        }
+        return result;
+    }
+
+    @Transactional
+    public TbMsWebMemberDto accountLockFree(String id) {
+        TbMsWebMember obj = requireOne(id);
+        obj.setAccountLockFree();
+        this.repo.save(obj);
+        return obj.toDto();
+    }
+}

+ 61 - 0
src/main/java/com/its/utils/AES256Util.java

@@ -0,0 +1,61 @@
+package com.its.utils;
+
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+
+public class AES256Util {
+    private String iv;
+    private Key keySpec;
+    
+    public static String DEFAULT_KEY = "qjeockd!csp#qs)x";
+    
+    public AES256Util(String key) throws UnsupportedEncodingException {
+        this.iv = key.substring(0, 16);
+ 
+        byte[] keyBytes = new byte[16];
+        byte[] b = key.getBytes("UTF-8");
+        int len = b.length;
+        if(len > keyBytes.length)
+            len = keyBytes.length;
+        System.arraycopy(b, 0, keyBytes, 0, len);
+        SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
+ 
+        this.keySpec = keySpec;
+    }
+ 
+    public String aesEncode(String str) throws UnsupportedEncodingException, NoSuchAlgorithmException,
+                                                     NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException,
+                                                     IllegalBlockSizeException, BadPaddingException{
+        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        c.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(iv.getBytes()));
+ 
+        byte[] encrypted = c.doFinal(str.getBytes("UTF-8"));
+        String enStr = new String(Base64.encodeBase64(encrypted));
+ 
+        return enStr;
+    }
+ 
+    //��ȣȭ
+    public String aesDecode(String str) throws UnsupportedEncodingException, NoSuchAlgorithmException,
+                                                     NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException,
+                                                     IllegalBlockSizeException, BadPaddingException {
+        Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        c.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(iv.getBytes("UTF-8")));
+ 
+        byte[] byteStr = Base64.decodeBase64(str.getBytes());
+ 
+        return new String(c.doFinal(byteStr),"UTF-8");
+    }
+    
+}